package com.central.apps.common.feign;

import com.central.common.feign.FeignExceptionConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @author JHY
 */
@FeignClient(value = "auth-server")//, configuration = {FeignExceptionConfig.class}
public interface AuthClient {
    @PostMapping(value = "/api-auth/oauth/username/token", headers = {"client_id=webApp", "client_secret=webApp"})
    Map<String, Object> getUserTokenInfoByName(@RequestParam(value = "username") String username,
                               @RequestParam HttpServletRequest request, @RequestParam HttpServletResponse response);

    @PostMapping(value = "/api-auth/oauth/user/token", headers = {"client_id=webApp", "client_secret=webApp"})
    void getUserTokenInfo(@RequestParam(value = "username") String username,
                          @RequestParam("password") String password,
                          @RequestParam HttpServletRequest request, @RequestParam HttpServletResponse response);

    @PostMapping(value = "/api-auth/oauth/get/token")
    OAuth2AccessToken getTokenInfo(@RequestParam(value = "access_token") String access_token);
}
